/**
 * 
 */
package com.gr.staffpm.pages.management.resources.team;

import java.util.List;

import com.gr.staffpm.dhtmlx.datatypes.Project;
import com.gr.staffpm.dhtmlx.datatypes.Task;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;


/**
 * @author Graham Rhodes 21 Jan 2011 15:24:50
 */
public class TeamResourcesXMLSerializer {

    public static String toXMLString(List<Project> projects) {
        XStream xstream = new XStream(new DomDriver());
        xstream.alias("projects", List.class);
        xstream.alias("project", Project.class);
        xstream.useAttributeFor(Project.class, "id");
        xstream.useAttributeFor(Project.class, "name");
        xstream.useAttributeFor(Project.class, "startdate");
        xstream.addImplicitCollection(Project.class, "tasks");
        xstream.alias("task", Task.class);
        xstream.useAttributeFor(Task.class, "id");

        return xstream.toXML(projects).replace("\n", "");
    }

}
